from ronglian_sms_sdk import SmsSDK
import random
import redis

accId = '8aaf0708827c8fd50182aa9346dd07bd'
accToken = '77396a7027d5497c967748a42d79cb36'
appId = '8aaf0708827c8fd50182aa9347d007c4'

def send_message(mobile):
    sdk = SmsSDK(accId, accToken, appId)
    tid = '1'
    # mobile = '手机号1,手机号2'
    code = random.randint(100000,999999)
    datas = (code, 5)
    resp = sdk.sendMessage(tid, mobile, datas)
    print(resp)
    # 将验证码存入redis
    rds = redis.Redis()
    key = 'sms_%s' % mobile
    rds.set(key,code,ex=60 * 5)
    # 数据库关闭
    return resp
